
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>注册</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="keywords" content="fly,layui,前端社区">
  <meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
    <link rel="stylesheet" href="../../res/layui/css/layui.css">
    <link rel="stylesheet" href="../../res/css/global.css">
</head>
<body>

<div class="fly-header layui-bg-black">
    <div class="layui-container">
        <a class="fly-logo" href="/">
            <img src="/images/logo.png" alt="layui" style="width: 105px;">
        </a>
        <ul class="layui-nav fly-nav-user" id="tabYe">

        </ul>
    </div>
</div>

<div class="layui-container fly-marginTop">
  <div class="fly-panel fly-panel-user" pad20>
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title">
        <li><a href="login.html">登入</a></li>
        <li class="layui-this">注册</li>
      </ul>
      <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
        <div class="layui-tab-item layui-show">
          <div class="layui-form layui-form-pane">
              <div class="layui-form-item">
                <label for="L_name" class="layui-form-label">姓　名</label>
                <div class="layui-input-inline">
                  <input type="text" id="L_name" name="email" required lay-verify="email" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">用户名</label>
                <div class="layui-input-inline">
                  <input type="text" id="L_username" name="username" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">将会成为您唯一的登入名</div>
              </div>
              <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label">密　码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_pass" name="pass" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <!--<div class="layui-form-mid layui-word-aux">6到16个字符</div>-->
              </div>
              <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">确认密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_repass" name="repass" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <button onclick="register()" class="layui-btn" lay-filter="*">立即注册</button>
              </div>
          </div>
        </div>
      </div>
    </div>
  </div>

</div>

<div class="fly-footer">
    <p> 2018 &copy; <a href="https://gitee.com/chaofan2685_admin" target="_blank">炒饭 出品</a></p>
    <p>
        <a href="http://www.lishiots.com/" target="_blank">力石科技</a>
        <a href="tencent://message/?uin=894195915&Site=http://vps.shuidazhe.com&Menu=yes">交个朋友</a>
        <a href=mailto:chaofan2685@qq.com>问题反馈</a>
    </p>
</div>

<script src="../../res/layui/layui.all.js"></script>
<script src="/js/jquery.min.js"></script>
<script src="/js/common.variate.js"></script>
<script src="/js/common.method.js"></script>
<script src="/js/md5.js"></script>
<script>
    function register() {
        var name = document.getElementById('L_name').value;
        var userName = document.getElementById('L_username').value;
        var password = document.getElementById('L_pass').value;
        var password2 = document.getElementById('L_repass').value;
        if (isEmpty(name) || isEmpty(userName) || isEmpty(password) || isEmpty(password2)){
            layer.msg("必填项不能为空",{anim: 6});
            return false;
        }
        if (password != password2){
            layer.msg("两次输入密码不一致！",{anim: 6})
        }else {
            $.ajax({
                type: "POST",
                url: "/api/user/add",
                data: {userName:userName,password:md5(password),name:name},
                dataType: "json",
                success: function(data){
                    if (data.code == '8200'){
                        layer.msg('注册成功！', {
                            time: 0 //不自动关闭
                            ,btn: ['确定']
                            ,yes: function(index){
                                layer.close(index);
                                location.href = "/login.html"
                            }
                        });
                    }else {
                        layer.msg(data.message,{anim: 6})
                    }
                }
            });
        }

    }
</script>
</body>
</html>